From 6ffccd14a27be4c3236821c27dd93087c041f39e Mon Sep 17 00:00:00 2001 From: Raimond Spekking Date: Sat, 31 Oct 2009 09:35:29 +0000 Subject: [PATCH] * (bug 20478) Add a note to Special:Block when the IP is already globally blocked Works for blocks by TorBlock too ToDo: bug 20188 for blocked usernames by CentralAuth --- RELEASE-NOTES | 4 ++-- includes/specials/SpecialBlockip.php | 21 ++++++++++++++++++++- languages/messages/MessagesEn.php | 1 + maintenance/language/messages.inc | 1 + 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index ee5650b832..c3211261d3 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -266,8 +266,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN contains the number of revisions in the history * $wgStylePath and $wgLogo are now set in the default LocalSettings.php file. * (bug 20186) Allow filtering history for revision deletion. -* New hook getOtherBlockLogLink, called in Special:IPBlockList to show links - to block logs of other blocking extensions, i.e. GlobalBlocking +* New hook getOtherBlockLogLink, called in Special:IPBlockList and Special:Block + to show links to block logs of other blocking extensions, i.e. GlobalBlocking * Added search capabilities to SQLite backend * rebuildtextindex.php maintenance script now supports databases other than MySQL diff --git a/includes/specials/SpecialBlockip.php b/includes/specials/SpecialBlockip.php index 81bdb64289..ff76353d42 100644 --- a/includes/specials/SpecialBlockip.php +++ b/includes/specials/SpecialBlockip.php @@ -105,6 +105,9 @@ class IPBlockForm { $wgOut->setSubtitle( wfMsgHtml( 'formerror' ) ); $wgOut->addHTML( Xml::tags( 'p', array( 'class' => 'error' ), $msg ) ); } elseif( $this->BlockAddress ) { + # Get other blocks, i.e. from GlobalBlocking or TorBlock extension + wfRunHooks( 'getOtherBlockLogLink', array( &$otherBlockedMsgs, $this->BlockAddress ) ); + $userId = is_object( $user ) ? $user->getId() : 0; $currentBlock = Block::newFromDB( $this->BlockAddress, $userId ); if( !is_null( $currentBlock ) && !$currentBlock->mAuto && # The block exists and isn't an autoblock @@ -112,7 +115,6 @@ class IPBlockForm { # or if it is, the range is what we're about to block ( $currentBlock->mAddress == $this->BlockAddress ) ) ) { - $wgOut->addWikiMsg( 'ipb-needreblock', $this->BlockAddress ); $alreadyBlocked = true; # Set the block form settings to the existing block if( !$this->wasPosted ) { @@ -132,6 +134,23 @@ class IPBlockForm { } } + # Show other blocks from extensions, i.e. GlockBlocking and TorBlock + if( count( $otherBlockedMsgs ) ) { + $wgOut->addHTML( + Html::rawElement( 'h2', array(), wfMsgExt( 'ipb-otherblocks-header', 'parseinline', count( $otherBlockedMsgs ) ) ) . "\n" + ); + $list = ''; + foreach( $otherBlockedMsgs as $link ) { + $list .= Html::rawElement( 'li', array(), $link ) . "\n"; + } + $wgOut->addHTML( Html::rawElement( 'ul', array( 'class' => 'mw-blockip-alreadyblocked' ), $list ) . "\n" ); + } + + # Username/IP is blocked already locally + if( $alreadyBlocked ) { + $wgOut->addWikiMsg( 'ipb-needreblock', $this->BlockAddress ); + } + $scBlockExpiryOptions = wfMsgForContent( 'ipboptions' ); $showblockoptions = $scBlockExpiryOptions != '-'; diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index cc7c54d8d7..01241da597 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -2938,6 +2938,7 @@ See the [[Special:IPBlockList|IP block list]] for the list of currently operatio 'ipb-needreblock' => '== Already blocked == $1 is already blocked. Do you want to change the settings?', +'ipb-otherblocks-header' => 'Other {{PLURAL:$1|block|blocks}}', 'ipb_cant_unblock' => 'Error: Block ID $1 not found. It may have been unblocked already.', 'ipb_blocked_as_range' => 'Error: The IP $1 is not blocked directly and cannot be unblocked. diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 0e6173d9ed..dabbe268a6 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1967,6 +1967,7 @@ $wgMessageStructure = array( 'ipb_hide_invalid', 'ipb_already_blocked', 'ipb-needreblock', + 'ipb-otherblocks-header', 'ipb_cant_unblock', 'ipb_blocked_as_range', 'ip_range_invalid', -- 2.20.1